import { Router } from 'hyper-express';
import requireUser from '../../../middlewares/auth/requireUser';
import cache from '../../../middlewares/cache';
import rowLevelPermission from '../../../middlewares/auth/rowLevelPermission';
//#region AutoCreateCode
import { uctooAttachmentsController } from '../../../controllers';
const uctooattachmentsRouter = new Router();
const attachmentsController = new uctooAttachmentsController();

uctooattachmentsRouter.post('/add', requireUser, attachmentsController.add);
uctooattachmentsRouter.post('/edit', requireUser, rowLevelPermission('uctoo/attachments'), attachmentsController.edit);
uctooattachmentsRouter.post('/del', requireUser, rowLevelPermission('uctoo/attachments'), attachmentsController.delete);

//For getting attachments with permission control
uctooattachmentsRouter.get('/:id', requireUser,  rowLevelPermission('uctoo/attachments'), attachmentsController.getSingle);
uctooattachmentsRouter.get('/:limit/:page', requireUser,  rowLevelPermission('uctoo/attachments'), attachmentsController.getMany);
uctooattachmentsRouter.get('/:limit/:page/:skip', requireUser,  rowLevelPermission('uctoo/attachments'), attachmentsController.getMany);

//#endregion AutoCreateCode
uctooattachmentsRouter.post('/fileUpload', requireUser, attachmentsController.fileUpload);
export default uctooattachmentsRouter;
